<!DOCTYPE html>
<html>
<head>
    <title>Function Currying Example</title>
</head>
<body>
    <script type="text/javascript">
        function curry(fn){
            var args = Array.prototype.slice.call(arguments, 1);
            return function(){
                var innerArgs = Array.prototype.slice.call(arguments),
                    finalArgs = args.concat(innerArgs);
                return fn.apply(null, finalArgs);
            };
        }
    
        function add(num1, num2){
            return num1 + num2;
        }
        
        var curriedAdd = curry(add, 5);
        alert(curriedAdd(3));   //8

        var curriedAdd2 = curry(add, 5, 12);
        alert(curriedAdd2());   //17

    </script>
</body>
</html>
